package o15sqt;

import sun.reflect.generics.tree.ReturnType;

/**
 * @author shkstart
 * @create 2022-01-11-21:39
 */
public class Sqrt {

    public static void main(String[] args) {
        int i = mySqrt(2147483647);

        System.out.println(i);
    }

    public static int mySqrt(int x) {

        if (x == 1 || x == 0) {
            return x;
        }

        for (int i = 1; i <= 46340; i++) {
            if (i * i == x) {
                return i;
            }
            if (i == 46340) {
                return 46340;
            }
            if (i * i < x && (i + 1) * (i + 1) > x) {

                return i;
            }

        }
        return -1;

    }


}
